# -*- Python -*-

import os
import lit.formats
import lit.util

config.name = 'constantine'
config.suffixes = ['.c', '.cpp']
config.test_format = lit.formats.ShTest()
#config.environment
config.unsupported = False
config.on_clone = None
config.test_exec_root = os.path.dirname(__file__)
config.test_source_root = os.path.dirname(__file__)
config.excludes = []
config.target_triple = '-vg'

config.available_features = []
config.available_features.append('asserts')
config.available_features.append('crash-recovery')

def xclang(pieces):
    return [elem for piece in pieces for elem in ['-Xclang', piece]]

debug_plugin = [config.clang_bin, '-fsyntax-only'] + xclang(['-verify', '-load', '{}/src/libdebug.so'.format(config.constantine_obj_root), '-plugin', 'constantine'])

config.substitutions = [
     ('%verify_const',
         ' '.join([config.clang_bin, '-fsyntax-only'] + xclang(['-verify', '-load', '{}/src/libconstantine.so'.format(config.constantine_obj_root), '-plugin', 'constantine'])) ),
    ('%verify_variable_changes', ' '.join(debug_plugin + xclang(['-plugin-arg-constantine', '-mode=VariableChanges'])) ),
    ('%verify_variable_usages', ' '.join(debug_plugin + xclang(['-plugin-arg-constantine', '-mode=VariableUsages'])) ),
    ('%show_variables', ' '.join(debug_plugin + xclang(['-plugin-arg-constantine', '-mode=VariableDeclaration'])) ),
    ('%show_functions', ' '.join(debug_plugin + xclang(['-plugin-arg-constantine', '-mode=FunctionDeclaration'])) )
]
